<?php
class UserGoogleFriendConnect
{
	private $api;
	private $auth;
	
	public function __construct($auth)
	{
		$this->api = ConfigParser::get('google_friend_connect', 'api');
		$this->auth = $auth;
	}
	
	public function get()
	{
		$uri = $this->api['people'].$this->auth;
		// 创建一个新cURL资源
		$ch = curl_init();
		// 设置URL和相应的选项
		curl_setopt($ch, CURLOPT_URL, $uri);
		curl_setopt($ch, CURLOPT_FAILONERROR, true);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		// 抓取URI
		$result = curl_exec($ch);
		// 检查是否有错误发生
		if(curl_errno($ch))
		{
			return array();
		}
		//关闭cURL资源，并且释放系统资源
		curl_close($ch);
		$data = json_decode($result);
		$data_2 = array(
			'id' => $data->entry->id,
			'avatar_uri' => $data->entry->thumbnailUrl,
			'name' => $data->entry->displayName
		);
		return $data_2;
	}
}
?>